package com.google.code.mamule.order;

import com.google.code.mamule.user.User;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * Created with IntelliJ IDEA. User: borck_000 ; Date: 12/24/13 ; Time: 1:25 PM
 */
@Repository
public interface OrderRepository extends CrudRepository<Order, Long> {

  Order findByIdAndOwner(Long id, User owner);

  @Query("SELECT o FROM Order o WHERE o.owner = :owner ORDER BY o.date DESC")
  Iterable<Order> findAllFrom(@Param("owner") User owner);
}
